Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: enable TLS/SSL through local filepath in http source #359

Merged
merged 15 commits into from
Oct 6, 2021

Conversation

chenqi0805
Copy link
Collaborator

@chenqi0805 chenqi0805 commented Oct 5, 2021

Description

This PR

  • Refactors the otel-trace-source certificate model and provider into common plugin.
  • Add certificate provider factory in http source to reuse the refactored certificate providers
  • Add test coverage on https protocol in http source.

Note: For now we only support certificates from local file path corresponding to the config in Fluentbit HTTP plugin (client).

Issues Resolved

#358

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

laneholloway
laneholloway previously approved these changes Oct 5, 2021
Copy link
Contributor

@laneholloway laneholloway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few comments, they aren't blockers but we should open up issues on them so that we don't lose sight of fixing them.

implementation "com.linecorp.armeria:armeria:1.9.2"
implementation "commons-io:commons-io:2.11.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ought to move the versions of dependencies we use in multiple places out to the external file with the others that we've already defined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we have a versionsMap in our build-resources.gradle to provide this consistency.

Gradle 7 should help us improve this, but it is not possible to update presently due to the OpenSearch plugin.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add commons-io version into versionMap. There might be other common packages. We should do that in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make a separate PR for this.

@@ -44,8 +51,19 @@ public void start(Buffer<Record<String>> buffer) {
}
if (server == null) {
final ServerBuilder sb = Server.builder();
// TODO: allow tls/ssl
sb.http(sourceConfig.getPort());
if (sourceConfig.isSsl()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: do we want to have isSsl or isSSL given that SSL is an acronym and not a proper word?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think isSSL makes more sense. This getter is autogenerated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should stick with isSsl. Making initials lowercase is a common convention. For example, java.net.http.HttpRequest.

force 'commons-logging:commons-logging:1.2'
force 'org.apache.httpcomponents:httpclient:4.5.13'
force 'org.apache.httpcomponents:httpcore:4.4.13'
force "org.hdrhistogram:HdrHistogram:2.1.12"
force 'joda-time:joda-time:2.10.10'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this PR, but we really shouldn't be using Joda time since it is now included in the JDKs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be here because the OpenSearch build plugin brings in its own dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can dive into it later.

@@ -44,8 +51,19 @@ public void start(Buffer<Record<String>> buffer) {
}
if (server == null) {
final ServerBuilder sb = Server.builder();
// TODO: allow tls/ssl
sb.http(sourceConfig.getPort());
if (sourceConfig.isSsl()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should stick with isSsl. Making initials lowercase is a common convention. For example, java.net.http.HttpRequest.

implementation "com.linecorp.armeria:armeria:1.9.2"
implementation "commons-io:commons-io:2.11.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we have a versionsMap in our build-resources.gradle to provide this consistency.

Gradle 7 should help us improve this, but it is not possible to update presently due to the OpenSearch plugin.

@@ -60,6 +69,38 @@ public void testValidConfig() {
assertEquals(TEST_THREAD_COUNT, sourceConfig.getThreadCount());
assertEquals(TEST_MAX_CONNECTION_COUNT, sourceConfig.getMaxConnectionCount());
assertEquals(TEST_MAX_PENDING_REQUESTS, sourceConfig.getMaxPendingRequests());
assertFalse(sourceConfig.isSsl());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to start using Hamcrest consistently for assertions. But, this is fine for now.

force 'commons-logging:commons-logging:1.2'
force 'org.apache.httpcomponents:httpclient:4.5.13'
force 'org.apache.httpcomponents:httpcore:4.4.13'
force "org.hdrhistogram:HdrHistogram:2.1.12"
force 'joda-time:joda-time:2.10.10'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be here because the OpenSearch build plugin brings in its own dependencies.

laneholloway
laneholloway previously approved these changes Oct 6, 2021
}

public CertificateProvider getCertificateProvider() {
// TODO: support more certificate providers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make an issue for this, please.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* GitHub history for details.
*/

package com.amazon.dataprepper.plugins.source.loghttp.certificate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker for now, but do we want to centralize the SSL certificate logic so we don't have these CertificateProviderFactories all over the codebase?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I did not centralize this class in the PR is b/c right now it takes the source plugin config as input arg. We will need to refactor out a common SSLConfig with all possible relevant parameters in order to do this centralization. The SSLConfig will be reused by the existing source plugins. I will reserve it for future iteration and open an issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -16,8 +16,15 @@ dependencies {
api project(':data-prepper-api')
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
implementation "commons-io:commons-io:2.11.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing you have to fix now, but going forward, please use single quotes for Gradle strings. Double quotes are GStrings which are used for string interpolation.

@chenqi0805 chenqi0805 merged commit ba0d9f1 into opensearch-project:main Oct 6, 2021
@chenqi0805 chenqi0805 deleted the enh/allow-tls branch October 6, 2021 18:37
jianghancn pushed a commit to jianghancn/data-prepper that referenced this pull request Oct 27, 2021
…arch-project#359)

* ENH: ssl config parameters and tests

Signed-off-by: qchea <[email protected]>

* MAINT: comment string

Signed-off-by: qchea <[email protected]>

* REF: server SSLCertProvider into common plugin

Signed-off-by: qchea <[email protected]>

* TST: ssl enabled server

Signed-off-by: qchea <[email protected]>

* MAINT: TODO comment

Signed-off-by: qchea <[email protected]>

* MAINT: update README

Signed-off-by: qchea <[email protected]>

* STY: rename ssl related parameters and variables

Signed-off-by: qchea <[email protected]>

* ENH: ssl config parameters and tests

Signed-off-by: qchea <[email protected]>

* MAINT: comment string

Signed-off-by: qchea <[email protected]>

* REF: server SSLCertProvider into common plugin

Signed-off-by: qchea <[email protected]>

* TST: ssl enabled server

Signed-off-by: qchea <[email protected]>

* MAINT: TODO comment

Signed-off-by: qchea <[email protected]>

* MAINT: update README

Signed-off-by: qchea <[email protected]>

* STY: rename ssl related parameters and variables

Signed-off-by: qchea <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants